﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:model="clr-namespace:Projecturo.Model;assembly=Projecturo.Model">

    <Style TargetType="{x:Type ToggleButton}" x:Key="NoteToggleButtonStyle">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <Border Width="13" Height="13" HorizontalAlignment="Center" VerticalAlignment="Center" Background="Transparent">
                        <Border Width="9" Height="9" BorderBrush="Black" BorderThickness="1" SnapsToDevicePixels="true">
                            <Path x:Name="ExpandPath"
                              Margin="1,1,1,1"
                              Fill="Black"
                              Data="M 0 2 L 0 3 L 2 3 L 2 5 L 3 5 L 3 3 
                                    L 5 3 L 5 2 L 3 2 L 3 0 L 2 0 L 2 2 Z"/>
                        </Border>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsChecked"
                       Value="True">
                            <Setter Property="Data"
                        TargetName="ExpandPath"
                        Value="M 0 2 L 0 3 L 5 3 L 5 2 Z"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <DataTemplate x:Key="NoteListTemplate" DataType="{x:Type model:Note}">
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*" x:Name="SecondColumn"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition/>
                <RowDefinition/>
            </Grid.RowDefinitions>
            <ToggleButton x:Name="NoteToggleButton" Grid.Row="0" Grid.Column="0" Width="16" Height="16" VerticalAlignment="Top" Margin="2,2,2,2" Style="{StaticResource NoteToggleButtonStyle}"/>
            <StackPanel Grid.Column="1" Grid.Row="0" DockPanel.Dock="Top" Orientation="Horizontal" >
                <TextBlock x:Name="FirstNameBox" Text="{Binding CreatedBy.FirstName}"/>
                <TextBlock Text=" "/>
                <TextBlock x:Name="LastNameBox" Text="{Binding CreatedBy.LastName}"/>
                <TextBlock Text=", "/>
                <TextBlock x:Name="CreateDateBox" Text="{Binding CreateDate}"/>
            </StackPanel>
            <TextBlock x:Name="DetailBox" 
                       Grid.Column="1"
                       Grid.Row="1"
                       Visibility="Collapsed" 
                       Text="{Binding Message}" 
                       TextWrapping="Wrap" Width="{Binding ElementName=SecondColumn,Path=Width}"/>
        </Grid>
        <DataTemplate.Triggers>
            <Trigger Property="IsChecked" SourceName="NoteToggleButton" Value="True">
                <Setter TargetName="DetailBox" Property="Visibility" Value="Visible"/>
                <Setter TargetName="FirstNameBox" Property="FontWeight" Value="Bold"/>
                <Setter TargetName="LastNameBox" Property="FontWeight" Value="Bold"/>
                <Setter TargetName="CreateDateBox" Property="FontWeight" Value="Bold"/>
            </Trigger>
        </DataTemplate.Triggers>
    </DataTemplate>

    <Style x:Key="StretchedContainerStyle" TargetType="{x:Type ListBoxItem}">
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
    </Style>
    
</ResourceDictionary>